﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using EvertonApp.Data.UnitOfWork;
using EvertonApp.Transporte;

namespace EvertonApp.WebAPI.Controllers
{
    public class HiloController : ApiController
    {
        private ForoUoW _foro;

        public HiloController()
        {
            this._foro = new ForoUoW();
        }

        // GET api/hilo
        public IEnumerable<Hilo> Get()
        {
            IQueryable<Hilo> hilos = _foro.HilosRepository.GetAll();

            return hilos.AsEnumerable();
        }

        // GET api/hilo/5
        public Hilo Get(Guid id)
        {
            return _foro.HilosRepository.GetById(id);
        }

        // POST api/hilo
        public Hilo Post([FromBody]Hilo value)
        {
           return _foro.HilosRepository.Insert(value);
        }

        // PUT api/hilo/5
        public bool Put(Guid id, [FromBody]Hilo value)
        {
           return  _foro.HilosRepository.Update(id, value);
        }

        // DELETE api/hilo/5
        public bool Delete(Guid id)
        {
            return   _foro.HilosRepository.Delete(_foro.HilosRepository.GetById(id));
        }
    }
}
